<template>
  <div class="tableList">
    <el-table :data="tableData" height="350px">
      <el-table-column prop="addresseeEmail" label="邮件地址"></el-table-column>
      <el-table-column prop="custName" label="客户名称"></el-table-column>
      <el-table-column  label="邮件主题">
        <template slot-scope="scope">
          <span class="more">{{scope.row.emailSubject}}</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination class="fixed"
                   background align="right"
                   @current-change="handleCurrent"
                   @size-change="handleSizeChange"
                   :current-page="currentPage"
                   :page-size="currentSize"
                   layout="total, sizes, prev, pager, next, jumper"
                   :total="total">
    </el-pagination>
  </div>
</template>
<script>
    import {getTargetEmailList, getTargetEmailTitle} from '@/api/marketStatic/email'

    export default {
        name: "TableList",
        data() {
            return {
                tableData: [],
                currentPage: 1,
                currentSize: 10,
                total:0,
                type:1,
                ruleID:''
            };
        },
        methods: {
            init(ruleID,type){
                this.type = type;
                this.ruleID = ruleID;
                this.getList();
            },
            handleCurrent(val) {
                this.currentPage = val;
                this.getList();
            },
            handleSizeChange(val) {
                this.currentSize = val;
                this.handleCurrent(1)
            },
            //获取邮件列表
            getList() {
                const params = {
                    ruleId: parseInt(this.ruleID),
                    type: parseInt(this.type),
                    current: this.currentPage,
                    size: this.currentSize
                }
                getTargetEmailList(params).then(res => {
                    if (res.data.success) {
                        const result =  res.data.data;
                        this.tableData= result.records;
                        this.total = result.total;
                    }
                }).catch(err => {
                    console.log(err)
                })
            }
        }
    }
</script>

<style scoped>

</style>
